import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const rootRoutes :RouteRecordRaw[] = [
    {
        path: 'home',
        name: 'Home',
        meta: {
            cache: true
        },
        component: () => import('../views/Home/Home.vue')
    },
    {
        path: 'ai',
        name: 'Ai',
        meta: {
            cache: true
        },
        component: () => import('../views/Ai/Ai.vue')
    },
    {
        path: 'message',
        name: 'Message',
        meta: {
            cache: false
        },
        component: () => import('../views/Message/Message.vue')
    },
    {
        path: 'shoppingcart',
        name: 'ShoppingCart',
        meta: {
            cache: true
        },
        component: () => import('../views/ShoppingCart/ShoppingCart.vue')
    },
    {
        path: 'mine',
        name: 'Mine',
        meta: {
            cache: true
        },
        component: () => import('../views/Mine/Mine.vue')
    },
]

const routes :RouteRecordRaw[]= [
    {
        path: '/',
        name: 'App',
        component: () => import('../views/TheRoot.vue'),
        redirect: '/home',
        children: rootRoutes
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('../views/Login.vue')
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

export default router